/**
 * 
 */
jQuery(function($) {
	user.select.init({suppilerId:$("#suppilerId").val()});
});

var user= {
	select: {
	        init:function (params) {
	            var path=$("#context_hidden_id").val();
	            var suppilerId=params['suppilerId'];
	            $.ajax({
	                type:"get",
	                url:path+"/suppiler/queryList",
	                async:true,
	                dataType:"json",
	                success:function(result){
	                	if(result.success) {
	                		for (var i=0;i<result.data.length;i++){
	                			var label=result.data[i].name+"-"+result.data[i].legalPerson;
	                			var value=result.data[i].id;
	                			if (suppilerId==value){
	                				$("#suppiler-select").append("<option value='"+value+"' selected='selected'>"+label+"</option>")
	                			}else{
	                				$("#suppiler-select").append("<option value='"+value+"'>"+label+"</option>")
	                			}
	                		}
	                	}else{
	                		$("#suppiler-select").append("获取数据失败")
	                	}
	                    $("#suppiler-select").chosen();
	                }
	            });
	        }
	    }
	}